
//代理商报表接口
var p="1";
var success = "";
//var time = "";
//var type = "";
var username = "";
function tiaozhuan(p){
	var pageSize=$('.ui-select-pagesize').val();
	var keyWord=$(".keyWord").val();
	var d={};
	d.page=p;
	d.pageSize=pageSize;
	d.success=success;
//	d.time=time;
//	d.type=type;
	d.username=keyWord;
	$.ajax({
		url: url + "/common/queryLogs",
		type: 'POST',
		//		参数需转为字符串
		data: JSON.stringify(d),
		//		json跨域
		dataType: 'json',
		contentType: "application/json",
		beforeSend: function(XMLHttpRequest) {
			XMLHttpRequest.setRequestHeader("X-Token", token); 
		},
		useDefaultXhrHeader: false,
		success: function(result) {
			console.log(result);
			if(result.code == '0') {
				var data=result.data.rows;
				var html="";
				var errormsg = "";
				var typemsg = "";
				var ipmsg = "";
				for(var i in data){
					if(!data[i].errorMsg){
						errormsg ="-";
					}else{
						errormsg = data[i].errorMsg; 
					}
					if(!data[i].ip){
						ipmsg ="-";
					}else{
						ipmsg = data[i].ip; 
					}
					switch(data[i].type) {
					     case 1:
					        typemsg = "添加";
					        break;
					     case 2:
					        typemsg = "查询";
					        break;
				         case 3:
					        typemsg = "修改";
					        break;
					     case 4:
					        typemsg = "删除";
					        break;
					     case 5:
					        typemsg = "登录";
					        break;
					     case 6:
					        typemsg = "登出";
					        break;   
					     default:
					        typemsg = "其它";
					} 
					html += '<tr><td>'+data[i].createTime+'</td>';
					html += '<td>'+errormsg+'</td><td>'+data[i].id+'</td>';
					html += '<td>'+ipmsg+'</td><td>'+data[i].operation+'</td>';
					html += '<td>'+data[i].time+'</td><td>'+typemsg+'</td>';
					html += '<td>'+data[i].username+'</td>';
				}
				$(".list_dsp").html(html);
				var r=result.data.total;
					paging(p,pageSize,r);
			} else {
				isErr(result);
			}
		},
		err: function(err) {
			layer.msg("请求失败");
		}
	}); 
}
tiaozhuan(1);


//搜索按钮
$(".keyWord_btn").on("click",function(){

	p=1;
	tiaozhuan(p);
})
